import os
import time
from datetime import datetime
import logging


def getLogger(logName: str) -> logging.Logger:
    logger = logging.getLogger(logName)
    logger.setLevel(logging.DEBUG)
    ch = logging.StreamHandler()
    try:
        fh = logging.FileHandler(f'logs/{datetime.now().strftime("%Y-%m-%d")}.log', encoding='utf-8')
    except FileNotFoundError as e:
        path = e.filename.replace(f'\\{datetime.now().strftime("%Y-%m-%d")}.log', "")
        os.mkdir(path)
        fh = logging.FileHandler(f'logs/{datetime.now().strftime("%Y-%m-%d")}.log', encoding='utf-8')
    formatter = logging.Formatter(
        '%(asctime)s : | %(filename)s -> %(module)s -> %(funcName)s |: [%(levelname)s: %(lineno)d]: %(message)s')
    ch.setFormatter(formatter)
    fh.setFormatter(formatter)
    logger.addHandler(ch)
    logger.addHandler(fh)
    return logger
